/**
 * @file ebex_filter_cfg.h
 *
 * @date Oct 19, 2011
 * @author seth
 *
 * @brief This file is part of EBEX State Estimator, created for the EBEX project
 *
 * This software is copyright (C) 2011 Columbia University
 *
 * EBEX State Estimator is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * EBEX State Estimator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with EBEX State Estimator; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef EBEX_FILTER_CFG_H_
#define EBEX_FILTER_CFG_H_

#include <random_util.h>
#include <ebex_quaternion.h>
#include <gyros.h>
#include <starcamera.h>
#include <ebex_genetic.h>
#include <data_file.h>
#include <ebex_statistics.h>

typedef struct
{
	int			num_sc_images;
	int			num_segments;
	int			sc_segment_jump;

	double		err_tol;
	double		var_tol;
	double		gyro_noise_limit;

	size_t		max_iter;
	bool		force_exit;
	size_t		repetitions;
	int			type;
	size_t		population_size;

	e_genetic_seed_strategy	seed_strategy;
	diff_evo_strategy_t		de_strategy;
	diff_evo_crossover_t	de_crossover;
	diff_evo_reference_t	de_reference;

	double		de_crossover_ratio;
	size_t		de_numvec;
	double		de_minweight;
	double		de_maxweight;
	double		de_opposition_rate;
	bool		de_scatter;
	double		de_scatter_min_improvement;

	char				*output_filename;
	data_file_types_t 	output_type;
	data_source_t		*output;

	bool		rotate_solution;
	bool		offset_solution;
	bool		backward_smoothing;

} ebex_bootstrap_cfg_t;

typedef struct
{
	size_t		parameter_population_size;
	size_t		generations_per_step;

	size_t		max_segments;
	size_t		eval_segments;

	size_t		convergence_window_size;
	double		convergence_sigma;
	bool		convergence_continue;

	size_t		state_population_size;
	size_t		minimum_effective_size;

	double		mating_ratio;
	double		organism_mutation_likelihood;

	e_genetic_mutation_type mutation_type;
	e_genetic_select_type	mutation_selection_type;
	e_genetic_mating_type	mating_type;
	e_genetic_select_type	mating_selection_type;

	genetic_selection_mode_t elitism_type;
	unsigned int			evolution_type;
	hill_climb_type_t		adaptation_type;

	e_ebex_quat_filter_type	quaternion_filter_type;
	size_t					adaptation_max_iter;

	double					learning_ratio;

	char					*output_filename;
	data_file_types_t 		output_type;
	data_source_t			*output;

	double 					weighting_range;
} ebex_ss_cfg_t;

typedef struct
{
	int			initial_size;
	int			minimum_effective_size;

	random_sample_3d_t	quaternion_sample;
	double				bandwidth;

	int			quaternion_filter_type;

} ebex_pf_cfg_t;

typedef struct
{
	gyrobox_t  gyro_box[2];
	sc_param_t  sc[2];

	data_file_t gyro_files[2][4];	/// 2 boxes, 3 gyros, 1 timestream
	data_file_t sc_files[2][7];		/// 2 cameras, 3 angles, 1 timestream, 3 uncertainties

	size_t		num_gyros;
	size_t		num_sc;

	int			loglevel;
	int			reference_gyrobox;
	double		gyro_rate;

	bool			smooth_gyros;
	e_kernel_type	smoothing_kernel;
	double			smoothing_bandwidth;

	/// ML section
	ebex_bootstrap_cfg_t 	bootstrap;
	ebex_ss_cfg_t			steady_state;

	/// State section
	ebex_pf_cfg_t			pf_configuration;

	/// Parent Output
	bool		output_parent;
	data_file_t parent_files[3];

} ebex_filter_cfg_t;

extern ebex_filter_cfg_t filter_config;

void ebex_filter_cfg_register(void);

#endif /* EBEX_FILTER_CFG_H_ */
